# -*- coding: utf-8 -*-
import pymysql

connect = pymysql.Connect(host="localhost", user="zengchen", password="zengchen233", database="big_data")

if connect:
    print("连接成功")
    try:
        with connect.cursor() as cursor:
            sql = '''select * from city_temp;'''
            cursor.execute(sql)
            fetchall = cursor.fetchall()
            for row in fetchall:
                print(row)
    except pymysql.err as e:
        print("Mysql Error %d: %s" % (e.args[0], e.args[1]))
    finally:
        cursor.close()
        # connect.close()

